/*
 * Created by JFormDesigner on Sun May 18 22:53:47 GMT+08:00 2025
 */

package com.soft.bams.client;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author wzs
 */
public class MainPanel extends JPanel {

    private ATMClient atm;

    public MainPanel(ATMClient atm) {
        this.atm = atm;
        initComponents();
    }

    //点击注册按钮
    private void register(ActionEvent e) {
        //获取当前MainPanel的父窗口（ATMClient JFrame） ->  获取它的布局方式  -> 跳转
        CardLayout cardLayout = (CardLayout)this.getParent().getLayout();
        //跳转至注册界面
        cardLayout.show(this.getParent() , "registerPanel");
    }

    //点击登录按钮
    private void login(ActionEvent e) {
        //获取当前MainPanel的父窗口（ATMClient JFrame） ->  获取它的布局方式  -> 跳转
        CardLayout cardLayout = (CardLayout)this.getParent().getLayout();
        //跳转至登录界面
        cardLayout.show(this.getParent() , "loginPanel");
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        titleLabel = new JLabel();
        registerButton = new JButton();
        loginButton = new JButton();

        //======== this ========
        setLayout(null);

        //---- titleLabel ----
        titleLabel.setText("\u6a21\u62dfICBC ATM\u7ec8\u7aef");
        titleLabel.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 20));
        titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
        add(titleLabel);
        titleLabel.setBounds(195, 45, 220, 55);

        //---- registerButton ----
        registerButton.setText("\u6ce8\u518c");
        registerButton.addActionListener(e -> register(e));
        add(registerButton);
        registerButton.setBounds(115, 195, 80, 35);

        //---- loginButton ----
        loginButton.setText("\u767b\u5f55");
        loginButton.addActionListener(e -> login(e));
        add(loginButton);
        loginButton.setBounds(430, 195, 80, 35);

        setPreferredSize(new Dimension(620, 340));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JLabel titleLabel;
    private JButton registerButton;
    private JButton loginButton;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
